iT邦幫忙

2025 iThome 鐵人賽

DAY 3
1
Software Development

30 天的 .Net gRPC 迷途系列 第 3

Day3 gRPC 欄位屬性介紹

  • 分享至 

  • xImage
  •  

gRPC 屬性介紹

gRPC 是由 Google 開發的高效能、開源的遠端程序調用 (RPC) 框架,可在不同環境中運行。以下是 gRPC 的主要屬性及其與 .NET 的對應關係:

基本純量實值屬性

在使用上都是有預設值不可為 null,如果需要可以為 null 的型態,要 Import wrappers.proto 使用

.NET 類型 Protobuf 型別 .NET 類型 已知型別包裝函式
double double bool? google.protobuf.BoolValue
float float double? google.protobuf.DoubleValue
int int32 float? google.protobuf.FloatValue
long int64 int? google.protobuf.Int32Value
uint uint32 long? google.protobuf.Int64Value
ulong uint64 uint? google.protobuf.UInt32Value
int sint32 ulong? google.protobuf.UInt64Value
long sint64 string google.protobuf.StringValue
uint fixed32 ByteString google.protobuf.BytesValue
ulong fixed64
int sfixed32
long sfixed64
bool bool
string string
ByteString bytes

日期和時間

.NET 類型 Protobuf 已知型別
DateTimeOffset google.protobuf.Timestamp
DateTime google.protobuf.Timestamp
TimeSpan google.protobuf.Duration

以上就是 gRPC 對應 .Net 的一些型別對應,在後面撰寫 .proto 檔的時候就會用上。


上一篇
Day2 認識 gRPC
下一篇
Day4 建立基本 gRPC Server 服務
系列文
30 天的 .Net gRPC 迷途9
圖片
  熱門推薦
圖片
{{ item.channelVendor }} | {{ item.webinarstarted }} |
{{ formatDate(item.duration) }}
直播中

尚未有邦友留言

立即登入留言